<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24" type="flex" align="middle">
          <a-col flex="450px">
            <a-form-item label="">
              <a-input-group compact>
                <a-select v-model="queryParam.searchField" :dropdownMatchSelectWidth="false">
                  <a-select-option value="project_change_no"> 变更单号 </a-select-option>
                  <a-select-option value="projectNo"> 项目编号 </a-select-option>
                  <a-select-option value="projectName"> 项目名称 </a-select-option>
                  <a-select-option value="projectManagerUserName"> 项目经理 </a-select-option>
                  <a-select-option value="dutyUserName"> 主要责任人 </a-select-option>
                </a-select>
                <a-input-search
                  style="width: 75%"
                  v-model="queryParam.keyword"
                  @search="searchQuery"
                  placeholder="请按照关键字进行搜索"
                />
              </a-input-group>
            </a-form-item>
          </a-col>
          <a-col flex="auto">
            <span class="flex-btn-line">
              <a-button type="primary" @click="showSearchForm = true" icon="search">高级查询</a-button>
              <a-button
                type="primary"
                @click="handlePostExportXls('项目转储报表')"                
                icon="download"
                >导出</a-button
              >
              <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>

      <a-modal
        :visible="showSearchForm"
        width="70vw"
        :bodyStyle="{ padding: '10px' }"
        title="高级查询"
        @ok="handleToSearch"
        @cancel="showSearchForm = false"
      >
        <a-form-model ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol">
          <a-row :gutter="24">
            <a-col :span="8">
              <a-form-model-item label="审批状态">
                <a-select v-model="queryParam.status">
                  <a-select-option value="1"> 创建中 </a-select-option>
                  <a-select-option value="2"> 审批中 </a-select-option>
                  <a-select-option value="3"> 审批完成 </a-select-option>
                  <a-select-option value="4"> 不同意 </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目编号">
                <a-input v-model="queryParam.projectNo" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目名称">
                <a-input v-model="queryParam.projectName" />
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row :gutter="24">
           
            <a-col :span="8">
              <a-form-model-item label="项目经理">
                <a-input v-model="queryParam.projectManagerUserName" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="申请人">
                <a-input v-model="queryParam.createUserName" />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-modal>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator"></div>
    <div class="container">
      <a-table
        ref="table"
        bordered
        size="middle"
        :scroll="{ x: 1800 }"
        :rowKey="rowKey"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange, columnWidth: 40 }"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="projectNo" slot-scope="text, record">
          <a @click="goProject(record)">{{ record.projectNo }}</a>
        </template>
        <template slot="projectChangeNo" slot-scope="text, record">
          <a @click="goProjectChange(record)">{{ record.projectChangeNo }}</a>
        </template>
        <template slot="changeReason" slot-scope="text, record">
          <span :title="record.changeReason">{{ showLength(record.changeReason, 15) }}</span>
        </template>
      </a-table>
    </div>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListSearchMixin'
import { getAction } from '@/api/manage'
export default {
  name: 'projectReserveList',
  mixins: [JeecgListMixin],
  data() {
    return {
      description: '项目变更报表',
      /* 勾选导出参数 */
      rowKey: 'id',
      busType: 'projectReserveList',
      columns: [
        {
          title: '审批状态',
          align: 'center',
          width: 65,
          dataIndex: 'statusText'
        },
        // {
        //   title: '转储单号',
        //   align: 'center',
        //   width: 100,
        //   scopedSlots: { customRender: 'projectNo' },
        //   sorter: (a, b) => a.projectNo - b.projectNo
        // },
        {
          title: '项目编号',
          align: 'center',
          width: 80,
          scopedSlots: { customRender: 'projectNo' }
        },
        {
          title: '项目名称',
          align: 'center',
          width: 130,
          dataIndex: 'projectName'
        },
        {
          title: '项目等级',
          align: 'center',
          width: 130,
          dataIndex: 'projectLevel'
        },
        {
          title: '项目经理',
          align: 'center',
          width: 80,
          dataIndex: 'projectManagerRealName'
        },
        {
          title: '转储原因',
          align: 'center',
          width: 80,
          dataIndex: 'reserveReason'
        },
        {
          title: '申请人',
          align: 'center',
          width: 60,
          dataIndex: 'createUserName'
        },
        {
          title: '申请时间',
          align: 'center',
          width: 80,
          dataIndex: 'submitTime'
        }
      ],
      url: {
        list: '/projectBuildReserve/reportPage',
        exportXlsUrl: '/projectBuildReserve/reportExportList'
      },
      showSearchForm: false,
      keyword: '',
      labelCol: { span: 8 },
      wrapperCol: { span: 15 },
      queryParam: {
        searchField: 'project_change_no',
        projectClassList: ['all']
      }
    }
  },
  mounted() {},
  computed: {},
  methods: {
    goProject(record) {
      let urlJump = this.$router.resolve({ path: '/approval?projectBuildId=' + record.projectBuildId })
      window.open(urlJump.href, '_blank')
    },
    goProjectChange(record) {
      let urlJump = this.$router.resolve({
        path:
          '/projectbuildstup/changeRecord?projectBuildId=' + record.projectBuildId + '&pageId=8&changeId=' + record.id
      })
      window.open(urlJump.href, '_blank')
    },
    handleToSearch() {
      this.showSearchForm = false
      this.searchQuery()
    },
    searchReset() {
      this.queryParam = {}
      this.queryParam.projectClassList = ['all']
      this.queryParam.searchField = 'project_change_no'
      this.handleToSearch()
    },
    showLength(item, len) {
      if (!item || item.length <= len) {
        return item
      }
      return item.substring(0, len) + '...'
    },
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/hte-main.less';
@media (max-width: 1170px) {
  .page-main .container section .list-content > div.flex-num1-box {
    flex-wrap: wrap;
    > div {
      &:nth-child(1),
      &:nth-child(2) {
        width: 48%;
      }
      &:nth-child(3) {
        width: 100%;
        justify-content: flex-start;
        > span {
          margin-right: 20px;
          margin-left: 0;
        }
      }
    }
  }
  .page-main .container section .list-content > div.flex-num2-box {
    display: block;
    margin-top: 0;
  }
}
</style>
